package org.openstock.impl.def.charting.ui.swing.presenter.delegate.builder;

import org.openstock.api.charting.presenter.delegate.builder.ViewBuilder;
import org.openstock.impl.def.charting.ui.swing.model.DefaultSwingStockChart;
import org.openstock.impl.def.charting.ui.swing.view.DefaultStockChartView;
import org.openstock.impl.def.core.factory.Factory;

public class DefaultStockChartViewBuilder implements
		ViewBuilder<DefaultStockChartView> {

	private DefaultSwingStockChartBuilder defaultSwingStockChartBuilder;
	
	public DefaultStockChartViewBuilder() {
		defaultSwingStockChartBuilder = Factory.getSingleton(DefaultSwingStockChartBuilder.class);
	}
	
	@Override
	public DefaultStockChartView build() {
		DefaultStockChartView view = buildInternal();
		DefaultSwingStockChart chart = defaultSwingStockChartBuilder.build();
		view.addChild(chart);
		return view;
	}
	
	private DefaultStockChartView buildInternal(){
		return Factory.getPrototype(DefaultStockChartView.class);
	}

}
